<?php

/*
Zoo Management Simulation
This file adds entry information from addCageEntry.php
*/

include("dbconnect.php");
if ($_REQUEST['submit'] == "Return to Administator page"){
	header('Location: index.php');
}

$numEntries = $_REQUEST['numentry'];
$entrynumber = 1;
$cageid = $_REQUEST['cageid'];

$idSql = "(SELECT max(Entry_Id)+1 FROM entry)";
$idResult = mysql_query($idSql);
while(($row = mysql_fetch_row($idResult)) !== FALSE)
	{
		$id = $row[0];
	}

while ($entrynumber <= $numEntries)
	{
		$doortype = $_REQUEST["doortype".$entrynumber];
		$doorstatus = $_REQUEST["doorstatus".$entrynumber];
		$entrysql = "INSERT INTO `entry`(`Entry_Id`, `Cage_Id`, `Entry_Desc`, `Entry_Status`) VALUES (".$id.",".$cageid.",'".$doortype."','".$doorstatus."')";
		$entryResult = mysql_query($entrysql);
		$id+=1;
		$entrynumber+=1;
	}
header('Location: index.php');

?>